package com.yoo.ons.function.me.like

import android.annotation.SuppressLint
import android.os.Build
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.RequiresApi
import androidx.recyclerview.widget.RecyclerView
import com.yoo.module_base.utils.setOnClickCallback
import com.yoo.ons.base.adpater.AdapterCallback
import com.yoo.ons.databinding.ItemLikeMyListBinding
import com.yoo.ons.model.WlmSubListModel
import com.yoo.ons.util.ImageCached.thumbnail
import com.yoo.ons.util.Injections.screenWidthD2
import com.yoo.ons.util.load
import jp.wasabeef.glide.transformations.BlurTransformation

class MyLikeListViewHolder(
    parent: ViewGroup,
    callback: AdapterCallback,
    private val binding: ItemLikeMyListBinding = ItemLikeMyListBinding.inflate(
        LayoutInflater.from(parent.context),
        parent,
        false,
    )
) : RecyclerView.ViewHolder(binding.root) {

    init {
        binding.imgItemLikeListFlashChat.setOnClickCallback {
            callback.invoke(MY_LIKE_LIST_ITEM_FLASH_CHAT,itemView)
        }
        binding.imgItemLikeCover.setOnClickCallback {
            callback.invoke(MY_LIKE_LIST_ITEM_PROFILE_INFO,itemView)
        }
    }

    @SuppressLint("SetTextI18n")
    @RequiresApi(Build.VERSION_CODES.S)
    fun bind(item: WlmSubListModel, position: Int) {
        itemView.tag = item
//        binding.imgItemLikeCover.load(
//            thumbnail(item.avatarUrl, width = screenWidthD2, quality = 75), placeHolder = null,
//            errorHolder = null, transformation = BlurTransformation(5, 5)
//        )
        binding.imgItemLikeCover.load(
            thumbnail(item.avatarUrl, width = screenWidthD2, quality = 75), placeHolder = null,
            errorHolder = null
        )
        binding.txtItemLikeNikeName.text = "${item.nickName},${item.age}"
        binding.txtItemLikeTag.setTags(item.interests.map { it.interest })
    }

}